//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
// -----------------------------------------------------------------------------
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//  
// -----------------------------------------------------------------------------


#ifndef __HALFUNC_H__
#define __HALFUNC_H__

#define HALFUNC DWORD __stdcall

// HALInit
EXTERN_C BOOL WINAPI HALInit(
	LPDDHALINFO lpddhi,
	BOOL reset,
	DWORD modeidx );


// DDraw HAL functions

//DDHAL_DDCALLBACKS
DWORD WINAPI HalDestroyDriver( LPDDHAL_DESTROYDRIVERDATA );
DWORD WINAPI HalCreateSurface( LPDDHAL_CREATESURFACEDATA );
DWORD WINAPI HalSetColorKey( LPDDHAL_DRVSETCOLORKEYDATA );
DWORD WINAPI HalSetMode( LPDDHAL_SETMODEDATA );
DWORD WINAPI HalWaitForVerticalBlank( LPDDHAL_WAITFORVERTICALBLANKDATA );
DWORD WINAPI HalCanCreateSurface( LPDDHAL_CANCREATESURFACEDATA );
DWORD WINAPI HalCreatePalette( LPDDHAL_CREATEPALETTEDATA );
DWORD WINAPI HalGetScanLine( LPDDHAL_GETSCANLINEDATA );
DWORD WINAPI HalSetExclusiveMode( LPDDHAL_SETEXCLUSIVEMODEDATA );
DWORD WINAPI HalFlipToGDISurface( LPDDHAL_FLIPTOGDISURFACEDATA );

// DDHAL_DDCOLORCONTROLCALLBACKS
DWORD WINAPI HalColorControl ( LPDDHAL_COLORCONTROLDATA );

// DDHAL_DDEXEBUFCALLBACKS
DWORD WINAPI CanCreateExecuteBuffer( LPDDHAL_CANCREATESURFACEDATA );
DWORD WINAPI HalCreateExecuteBuffer( LPDDHAL_CREATESURFACEDATA );
DWORD WINAPI HalDestroyExecuteBuffer( LPDDHAL_DESTROYSURFACEDATA );
DWORD WINAPI HalLockExecuteBuffer( LPDDHAL_LOCKDATA );
DWORD WINAPI HalUnlockExecuteBuffer( LPDDHAL_UNLOCKDATA );

// DDHAL_DDKERNELCALLBACKS
DWORD WINAPI HalSyncSurfaceData(LPDDHAL_SYNCSURFACEDATA);
DWORD WINAPI HalSyncVideoPortData(LPDDHAL_SYNCVIDEOPORTDATA);

// DDHAL_DDMISCELLANEOUSCALLBACKS
DWORD WINAPI HalGetAvailDriverMemory(LPDDHAL_GETAVAILDRIVERMEMORYDATA);
DWORD WINAPI HalUpdateNonLocalHeap(LPDDHAL_UPDATENONLOCALHEAPDATA);
DWORD WINAPI HalGetHeapAlignment(LPDDHAL_GETHEAPALIGNMENTDATA);
DWORD WINAPI HalGetSysmemBltStatus(LPDDHAL_GETBLTSTATUSDATA);

// DDHAL_DDPALETTECALLBACKS
DWORD WINAPI HalDestroyPalette( LPDDHAL_DESTROYPALETTEDATA );
DWORD WINAPI HalSetEntries( LPDDHAL_SETENTRIESDATA );

// DDHAL_DDSURFACECALLBACKS
DWORD WINAPI HalDestroySurface( LPDDHAL_DESTROYSURFACEDATA );
DWORD WINAPI HalFlip( LPDDHAL_FLIPDATA );
DWORD WINAPI HalSetClipList( LPDDHAL_SETCLIPLISTDATA );
DWORD WINAPI HalLock( LPDDHAL_LOCKDATA );
DWORD WINAPI HalUnlock( LPDDHAL_UNLOCKDATA );
DWORD WINAPI HalBlt( LPDDHAL_BLTDATA );
DWORD WINAPI HalSetColorKey( LPDDHAL_SETCOLORKEYDATA );
DWORD WINAPI HalAddAttachedSurface( LPDDHAL_ADDATTACHEDSURFACEDATA );
DWORD WINAPI HalGetBltStatus( LPDDHAL_GETBLTSTATUSDATA );
DWORD WINAPI HalGetFlipStatus( LPDDHAL_GETFLIPSTATUSDATA );
DWORD WINAPI HalUpdateOverlay( LPDDHAL_UPDATEOVERLAYDATA );
DWORD WINAPI HalSetOverlayPosition( LPDDHAL_SETOVERLAYPOSITIONDATA );
DWORD WINAPI HalSetPalette( LPDDHAL_SETPALETTEDATA );

// DDHAL_DDHALMEMORYCALLBACKS
DWORD WINAPI HalGetVidMem(LPDDHAL_HALGETVIDMEMDATA pd);
DWORD WINAPI HalSetSurfaceDesc(LPDDHAL_HALSETSURFACEDESCDATA pd);

// DDHAL_DDVIDEOPORTCALLBACKS
DWORD WINAPI HalCanCreateVideoPort(LPDDHAL_CANCREATEVPORTDATA);
DWORD WINAPI HalCreateVideoPort(LPDDHAL_CREATEVPORTDATA);
DWORD WINAPI HalFlipVideoPort(LPDDHAL_FLIPVPORTDATA);
DWORD WINAPI HalGetVideoPortBandwidth(LPDDHAL_GETVPORTBANDWIDTHDATA);
DWORD WINAPI HalGetVideoPortInputFormats(LPDDHAL_GETVPORTINPUTFORMATDATA);
DWORD WINAPI HalGetVideoPortOutputFormats(LPDDHAL_GETVPORTOUTPUTFORMATDATA);
DWORD WINAPI HalGetVideoPortField(LPDDHAL_GETVPORTFIELDDATA);
DWORD WINAPI HalGetVideoPortLine(LPDDHAL_GETVPORTLINEDATA);
DWORD WINAPI HalGetVideoPortConnectInfo(LPDDHAL_GETVPORTCONNECTDATA);
DWORD WINAPI HalDestroyVideoPort(LPDDHAL_DESTROYVPORTDATA);
DWORD WINAPI HalGetVideoPortFlipStatus(LPDDHAL_GETVPORTFLIPSTATUSDATA);
DWORD WINAPI HalUpdateVideoPort(LPDDHAL_UPDATEVPORTDATA);
DWORD WINAPI HalWaitForVideoPortSync(LPDDHAL_WAITFORVPORTSYNCDATA);
DWORD WINAPI HalGetVideoSignalStatus(LPDDHAL_GETVPORTSIGNALDATA);
DWORD WINAPI HalColorControl(LPDDHAL_VPORTCOLORDATA);

// LPDDHAL_GETDRIVERINFO
DWORD WINAPI HalGetDriverInfo(LPDDHAL_GETDRIVERINFODATA lpInput);


#if 0
// D3D HAL functions
	 
HALFUNC HalContextCreate(LPD3DHAL_CONTEXTCREATEDATA);
HALFUNC HalContextDestroy(LPD3DHAL_CONTEXTDESTROYDATA);
HALFUNC HalContextDestroyAll(LPD3DHAL_CONTEXTDESTROYALLDATA);
// HALFUNC HalSceneCapture(LPD3DHAL_SCENECAPTUREDATA);
// HALFUNC HalExecute(LPD3DHAL_EXECUTEDATA);
// HALFUNC HalExecuteClipped(LPD3DHAL_EXECUTECLIPPEDDATA);
HALFUNC HalRenderState(LPD3DHAL_RENDERSTATEDATA);
HALFUNC HalRenderPrimitive(LPD3DHAL_RENDERPRIMITIVEDATA);
HALFUNC HalTextureCreate(LPD3DHAL_TEXTURECREATEDATA);
HALFUNC HalTextureDestroy(LPD3DHAL_TEXTUREDESTROYDATA);
HALFUNC HalTextureSwap(LPD3DHAL_TEXTURESWAPDATA);
HALFUNC HalTextureGetSurf(LPD3DHAL_TEXTUREGETSURFDATA);
// HALFUNC HalMatrixCreate(LPD3DHAL_MATRIXCREATEDATA);
// HALFUNC HalMatrixDestroy(LPD3DHAL_MATRIXDESTROYDATA);
// HALFUNC HalMatrixSetData(LPD3DHAL_MATRIXSETDATADATA);
// HALFUNC HalMatrixGetData(LPD3DHAL_MATRIXGETDATADATA);
// HALFUNC HalSetViewportData(LPD3DHAL_SETVIEWPORTDATADATA);
// HALFUNC HalLightSet(LPD3DHAL_LIGHTSETDATA);
// HALFUNC HalMaterialCreate(LPD3DHAL_MATERIALCREATEDATA);
// HALFUNC HalMaterialDestroy(LPD3DHAL_MATERIALDESTROYDATA);
// HALFUNC HalMaterialSetData(LPD3DHAL_MATERIALSETDATADATA);
// HALFUNC HalMaterialGetData(LPD3DHAL_MATERIALGETDATADATA);
HALFUNC HalGetState(LPD3DHAL_GETSTATEDATA);


// DX5 D3D functions
DWORD WINAPI HalDrawOnePrimitive(LPD3DHAL_DRAWONEPRIMITIVEDATA pd );
DWORD WINAPI HalDrawOneIndexedPrimitive(LPD3DHAL_DRAWONEINDEXEDPRIMITIVEDATA pd );
DWORD WINAPI HalDrawPrimitives(LPD3DHAL_DRAWPRIMITIVESDATA pd );
DWORD WINAPI HalClear(LPD3DHAL_CLEARDATA pd);
DWORD WINAPI HalSetRenderTarget(LPD3DHAL_SETRENDERTARGETDATA pd);
DWORD WINAPI HalSetHintState(LPD3DHAL_SETHINTSTATEDATA pd);
DWORD WINAPI HalGetHintState(LPD3DHAL_GETHINTSTATEDATA pd);
#endif



// callback structures

extern DDHAL_DDCALLBACKS cbDDCallbacks;
extern DDHAL_DDCOLORCONTROLCALLBACKS ColorControlCallbacks;
extern DDHAL_DDEXEBUFCALLBACKS cbDDExeBufCallbacks;
extern DDHAL_DDKERNELCALLBACKS KernelCallbacks;
extern DDHAL_DDMISCELLANEOUSCALLBACKS MiscellaneousCallbacks;
extern DDHAL_DDPALETTECALLBACKS cbDDPaletteCallbacks;
extern DDHAL_DDSURFACECALLBACKS cbDDSurfaceCallbacks;
extern DDHAL_DDHALMEMORYCALLBACKS HalMemoryCallbacks;
extern DDHAL_DDVIDEOPORTCALLBACKS VideoPortCallbacks;
//extern D3DHAL_CALLBACKS D3DHALCallbacks;
extern const DDKERNELCAPS KernelCaps;
extern const DDVIDEOPORTCAPS VideoPortCaps;

#ifdef D_MISCELLANEOUSCECALLBACKS
extern DDHAL_DDMISCELLANEOUSCECALLBACKS MiscellaneousCECallbacks;
#endif //D_MISCELLANEOUSCECALLBACKS
#if DIRECTDRAW_VERSION >= 0x0700
extern const DDMORECAPS MoreCaps;
extern DDHAL_DDMISCELLANEOUS2CALLBACKS Miscellaneous2Callbacks;
#endif //DIRECTDRAW_VERSION >= 0x0700


EXTERN_C DWORD WINAPI DDGPEFlipToGDISurface( LPDDHAL_FLIPTOGDISURFACEDATA pd );
EXTERN_C DWORD WINAPI DDGPEDestroyDriver( LPDDHAL_DESTROYDRIVERDATA pd );
#ifdef D_MISCELLANEOUSCECALLBACKS
EXTERN_C DWORD WINAPI DDGPEGetGDISurface( LPDDHAL_GETGDISURFACEDATA pd );
#endif //D_MISCELLANEOUSCECALLBACKS
EXTERN_C DWORD WINAPI DDGPESetMode( LPDDHAL_SETMODEDATA );
EXTERN_C DWORD WINAPI DDGPEWaitForVerticalBlank( LPDDHAL_WAITFORVERTICALBLANKDATA );
EXTERN_C DWORD WINAPI DDGPESetColorKeyDrv( LPDDHAL_DRVSETCOLORKEYDATA pd );
EXTERN_C DWORD WINAPI DDGPESetColorKey( LPDDHAL_SETCOLORKEYDATA pd );
EXTERN_C DWORD WINAPI DDGPECanCreateSurface( LPDDHAL_CANCREATESURFACEDATA );
EXTERN_C DWORD WINAPI DDGPECreateSurface( LPDDHAL_CREATESURFACEDATA pd );
EXTERN_C DWORD WINAPI DDGPECreateExecuteBuffer( LPDDHAL_CREATESURFACEDATA pd );
EXTERN_C DWORD WINAPI DDGPEDestroyExecuteBuffer( LPDDHAL_DESTROYSURFACEDATA pd );
EXTERN_C DWORD WINAPI DDGPELock( LPDDHAL_LOCKDATA pd );
EXTERN_C DWORD WINAPI DDGPEUnlock( LPDDHAL_UNLOCKDATA pd );
EXTERN_C DWORD WINAPI DDGPEDestroySurface( LPDDHAL_DESTROYSURFACEDATA pd );
EXTERN_C DWORD WINAPI DDGPEFlip( LPDDHAL_FLIPDATA pd );
EXTERN_C DWORD WINAPI DDGPEBlt( LPDDHAL_BLTDATA pd );
EXTERN_C DWORD WINAPI DDGPEGetFlipStatus( LPDDHAL_GETFLIPSTATUSDATA pd );
EXTERN_C DWORD WINAPI DDGPESetPalette( LPDDHAL_SETPALETTEDATA pd );
EXTERN_C DWORD WINAPI DDGPECreatePalette( LPDDHAL_CREATEPALETTEDATA pd );
EXTERN_C DWORD WINAPI DDGPEDestroyPalette( LPDDHAL_DESTROYPALETTEDATA pd );
EXTERN_C DWORD WINAPI DDGPESetEntries( LPDDHAL_SETENTRIESDATA pd );



EXTERN_C void buildDDHALInfo( LPDDHALINFO lpddhi, DWORD modeidx );


// set up by HalInit
extern DDGPE*			g_pGPE;
extern DDGPESurf*		g_pDDrawPrimarySurface;

// InitDDHALInfo must set up this information
extern unsigned long	g_nVideoMemorySize;
extern unsigned char *	g_pVideoMemory;	// virtual address of video memory from client's side


#endif // __HALFUNC_H__

